package reflect;

import reflect.annotation.AutoRunClass;

import java.util.Scanner;

public class Test3 {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一个类名：");
        String className = sc.nextLine();

        Class<?> cls = Class.forName(className);
        if (cls.isAnnotationPresent(AutoRunClass.class)) {
            System.out.println("该类被自动运行注解修饰了");
            Object obj = cls.newInstance();
            System.out.println(obj);
        }else {
            System.out.println("该类没有被自动运行注解修饰");
        }
    }
}
